﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using EZMemoLib;
using System.Windows.Media.Animation;

namespace Remember.WPF.Views
{
    /// <summary>
    /// Interaction logic for BookView.xaml
    /// </summary>
    public partial class BookView : UserControl
    {
        DoubleAnimation animFadeIn = new DoubleAnimation();
        DoubleAnimation animFadeOut = new DoubleAnimation();

        public BookView()
        {
            InitializeComponent();

            Build();

            animFadeIn = new DoubleAnimation();
            animFadeIn.From = 0;
            animFadeIn.To = 1;
            animFadeIn.Duration = new Duration(TimeSpan.FromMilliseconds(1600));
            this.BeginAnimation(OpacityProperty, animFadeIn);

            animFadeOut = new DoubleAnimation();
            animFadeOut.From = 1;
            animFadeOut.To = 0;
            animFadeOut.Duration = new Duration(TimeSpan.FromMilliseconds(500));

        }

        BookBusiness book = BookBusiness.Instance();

        void Build()
        {
            var list = book.GetBookList(0);

            foreach (var cat in list)
            {
                var bookItem = new BookItemControl();
                bookItem.uiBookName.Text = cat.CategoryName;
                
                this.uiListPanel.Children.Add(bookItem);
            }

        }
    }
}
